/**
* @author maze | guavestudios.com
* @license MIT License see LICENSE.TXT
* @version 0.1
*/
package com.guavestudios.fcon.commands {
	import com.guavestudios.fcon.api.INamedCommand;
	import com.guavestudios.fcon.api.IControlableConsole;
	import flash.utils.*;
	
	public class LoadCommandCommand implements INamedCommand{
		
		//{ STATIC
	
		//}
		
		//{ MEMBERS
		
		//}
		
		//{ GETTER-SETTER
		
		//}
		public function LoadCommandCommand() {
			
			
			init();	
		}
		private function init():void {
			
		}
		//{ PUBLIC FUNCTIONS
		public function execute(args:Array):void
		{
			var c:IControlableConsole=args[0] as IControlableConsole;
			
			if (args[1] is String)
			{
				var o:Object=getDefinitionByName(args[1]);
				if (o)
				{
					var n:INamedCommand=new o() as INamedCommand;
					c.addCommand(n);
					c.outputText("loadCommand: success: "+n.getCommandName()+" ("+args[1]+")");
				}
			}
			else if (args[1] is INamedCommand)
			{
				c.addCommand(args[1] as INamedCommand);
				
			}
			
			
		}
		public function getCommandName():String
		{
			return "loadCommand";
		}
		//}
		
		//{ OVERRIDEN METHODS
		
		//}
		
		//{ PRIVATE FUNCTIONS
		
		//}

	}
	
}
